<template>
	<view>
		<view class='searchStyl'>
			<u-search shape="square" v-model="keywords" bgColor="#FFFFFFS " placeholder="请输入经销商/车辆订单号" placeholderColor="#CDCDCD" :showAction="false" @click="doSearch(keywords)" @search="doSearch(keywords)"></u-search>
		</view>
		<view v-if="payCostList.length > 0">
		    
			<view class="item1" v-for="(item, index) in payCostList" :key="index" @click="itemClick(item)">

				<view class="title-wrap1">

					<text class="title-text">
						{{filterNull(item.rentTypeName)}}
					</text>

					<view class="title-warn">
						
					</view>
				</view>

				<u-line color="#efefef" dashed margin="0 0 15px"></u-line>

				<view class="text-line1">
					<text class="text-name">车辆订单号:</text>
					<text >{{filterNull(item.businessNo)}}</text>
				</view>
				
				<view class="text-line1">
					<text class="text-name">经销商:</text>
					<text >{{filterNull(item.tenantName)}}</text>
				</view>


				<view class="text-line1">
					<text class="text-name">租期:</text>
					<text>{{filterNull(item.timeStartRent)}}至{{filterNull(item.timeFinishRent)}}</text>
				</view>

				<view class="text-line1">
					<text class="text-name">车牌号:</text>
					<text class="text-value">{{filterNull(item.carPlateNo)}}</text>
				</view>

				<view class="text-line1">
					<text class="text-name">品牌/车系/车型:</text>
					<text>{{filterNull(item.brandName)}}/{{filterNull(item.seriesName)}}/{{filterNull(item.modelName)}}</text>
				</view>



				<view class="text-line1">
					<text class="text-name">付款类型:</text>
					<text class="text-value">{{filterNull(item.collectionTypeName)}}</text>
				</view>


				<view class="text-line1">
					<text class="text-name">记账周期:</text>
					<text >{{filterNull(item.billStartTime)}}至{{filterNull(item.billEndTime)}}</text>
				</view>


				<view class="text-line1">
					<text class="text-name">应付日期:</text>
					<text >{{filterNull(item.receivableDate)}}</text>
				</view>


				<view class="text-line1">
					<text class="text-name">逾期天数:</text>
					<text >{{item.overdueDays?item.overdueDays + '天':'0'}}</text>
				</view>
				<view class="text-line2">
					<image class="close-img" src="../../../../static/message_icon_tips@2x.png"></image>
					<text>费用单已出，请尽快还款</text>	
				</view>
				<view class="title-wrap1"
					v-if="isEnv!=3 && item.uncollectedAmount>0">

					<view class="title-warn">
						{{'付款金额：￥'+filterNull(item.uncollectedAmount)}}	
					</view>

					<view class="btn-detail1" @click.stop="itemClick(item)">
						详情
					</view>
				</view>

			</view>

			<u-loadmore v-if="pageNo>2" :status="loadingStatus" @loadmore="clickloadmore"></u-loadmore>
		</view>

		<no-data v-else></no-data>

	</view>
</template>

<script>
	import {
		receivablelist,
		commonenv
	} from '../../../../common/api.js';

	export default {
		data() {
			return {
				isEnv: 0,
				pageNo: 1,
				loadingStatus: 'loading',
				payCostList: [],
				keywords:''
			}
		},

		onShow() {
			this.pageNo = 1;
			this.getData();
			this.getEnv();
		},

		methods: {
			doSearch(){
				this.pageNo = 1;
				this.getData()
			},
			getEnv(){
				commonenv().then(res=>{
					this.isEnv = res;
				})
			},

			getData() {
				receivablelist({
					params: {
						pageNo: this.pageNo,
						keywords:this.keywords
					}
				}).then(res => {
					if (this.pageNo == 1) {
						this.payCostList = [];
						this.pageNo++;
						// uni.stopPullDownRefresh();

						this.loadingStatus = 'loadmore';
					} else {
						if (!uni.$u.test.isEmpty(res)) {
							this.pageNo++;

							this.loadingStatus = 'loadmore';
						} else {

							this.loadingStatus = 'nomore';
						}
					}

					if (!uni.$u.test.isEmpty(res)) {
						this.payCostList = this.payCostList.concat(res);
					}


				})
			},
			
			itemClick(item){
				uni.navigateTo({
					url:'./billdetail?receivablesId='+item.receivablesId
				})
				// if(item.receivablesId){
				// 	uni.navigateTo({
				// 		url:'./billdetail?receivablesId='+item.receivablesId
				// 	})
				// }
			},
			
			clickloadmore() {
				this.getData();
				this.showloading = true;
				this.loadingStatus = 'loading';
			},
			

		},
		onPullDownRefresh() {
			this.pageNo = 1;
			this.getData();
		},

		onReachBottom() {
			this.getData();
			this.showloading = true;
			this.loadingStatus = 'loading';
		}

	}
</script>

<style lang="scss" scoped>
	.searchStyl{
		height: 64upx;
		margin-top:24upx;
		background: #ffffff;
		margin:32upx;
		border-radius:8upx ;
	}
	.text-line2{
		height: 64upx;
		background-color: rgba(200, 221, 65, 0.20);
		display: flex;
		justify-content: flex-start;
		align-items: center;
		padding-left:32upx;
		border-radius: 4upx;
		.close-img{
			width: 32upx;
			height: 32upx;
			margin-right: 16upx;
		}
		text{
			font-size: 24upx;
			color:#173B42 ;
		}
	}
	.item1{
		background-color: #ffffff;
		padding:32upx;
		margin:32upx;
	}
	.text-line1{
		margin-bottom: 16upx;
		.text-name{
			margin-right: 8upx;
		}
		text{
			font-size: 24upx;
			color:#666666;
		}
	}
	.btn-detail1 {
		width: 120upx;
		height: 64upx;
		border-radius: 4upx;
		color: #173B42;
		text-align: center;
		font-size: 28upx;
		line-height: 64upx;
		margin: 10upx 20upx 10upx;
		border:2upx solid #173B42;
	}
	.title-wrap1 {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.title-text {
		width: 100%;
		font-size: 32upx;
		color: #000000;
		font-weight: bold;
		margin-bottom: 16upx;
	}

	.title-warn {
		color: #FF6A15;
		background-color: #FFFFFF;
		white-space: nowrap;
		font-size: 24upx;
		line-height: 60upx;
	}
	
</style>
